Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When prefixing with a data, eagerly get local name #1614

Merged
merged 2 commits into from
Oct 12, 2020

Conversation

jackkoenig
Copy link
Contributor

@jackkoenig jackkoenig commented Oct 12, 2020

Fixes #1606

Previously, the Data itself would be put on the prefix stack and its
full name would be used as the prefix for subsequent names. This meant
that prefixes would grow quadratically as the prefix is present both on
the Data pushed to the stack, and on the stack itself. This is fixed by
just using the "local" name of the Data being pushed on the stack.

A related issue is deferring the name resolution. This led to unintuitive
behavior when the name of a Data used as a prefix is overridden later
(usually when the Data is a return value). The overriding name would
show up in prefixes twice instead of once. It is much more intuitive to
grab the name at the moment of the connection creating the prefix rather
than deferring to later.

TODO

  • Fix linear lookup of aggregate children - proposal is to force the local names of aggregate children, this could violate weird assumptions so need to be careful Later
  • Switch implementation of prefix stack to List[String] - this will improve memory and performance a decent amount Later

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • bug fix

API Impact

No impact on API (changing types of methods on a package private object will require MiMa waivers but isn't visible to the user).

Backend Code Generation Impact

Improves names from recursive functions where prefixing occurs due to a connection quite a bit

Desired Merge Strategy

  • Squash

Release Notes

Fix quadratic naming in recursive functions (Fixes #1606)

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (3.2.x, 3.3.x, 3.4.0, 3.5.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

Fixes #1606

Previously, the Data itself would be put on the prefix stack and its
full name would be used as the prefix for subsequent names. This meant
that prefixes would grow quadratically as the prefix is present both on
the Data pushed to the stack, and on the stack itself. This is fixed by
just using the "local" name of the Data being pushed on the stack.

A related issue is deferring the name resolution. This led to unintuitive
behavior when the name of a Data used as a prefix is overridden later
(usually when the Data is a return value). The overriding name would
show up in prefixes twice instead of once. It is much more intuitive to
grab the name at the moment of the connection creating the prefix rather
than deferring to later.
@jackkoenig jackkoenig requested a review from azidar October 12, 2020 20:57
@jackkoenig
Copy link
Contributor Author

This is Draft for now because I want to try it out and see how well it works despite the linear lookup for names of aggregate children. I have an idea to fix it, but as mentioned it might violate bad assumptions so need to be careful.

I also want to change the prefix stack to be a List[String] since we no longer need to put Data on it, but maybe that should be a separate PR, thoughts @azidar?

@azidar
Copy link
Contributor

azidar commented Oct 12, 2020

I think separate PRs is good. Let's merge this ASAP.

@jackkoenig
Copy link
Contributor Author

Alright, do you think I should do https://github.com/freechipsproject/chisel3/pull/1614/files#diff-61c46b849f372e39e0c29dc7945edcbbR374 or if performance looks okay do that in follow on as well?

@azidar
Copy link
Contributor

azidar commented Oct 12, 2020

Let's do a follow-on PR.

@jackkoenig jackkoenig marked this pull request as ready for review October 12, 2020 21:14
@jackkoenig jackkoenig requested a review from a team as a code owner October 12, 2020 21:14
@jackkoenig jackkoenig added this to the 3.4.x milestone Oct 12, 2020
@jackkoenig
Copy link
Contributor Author

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Oct 12, 2020

Command refresh: success

Pull request refreshed

@jackkoenig jackkoenig added the Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI. label Oct 12, 2020
@mergify mergify bot merged commit 1b15dca into master Oct 12, 2020
mergify bot pushed a commit that referenced this pull request Oct 12, 2020
Fixes #1606

Previously, the Data itself would be put on the prefix stack and its
full name would be used as the prefix for subsequent names. This meant
that prefixes would grow quadratically as the prefix is present both on
the Data pushed to the stack, and on the stack itself. This is fixed by
just using the "local" name of the Data being pushed on the stack.

A related issue is deferring the name resolution. This led to unintuitive
behavior when the name of a Data used as a prefix is overridden later
(usually when the Data is a return value). The overriding name would
show up in prefixes twice instead of once. It is much more intuitive to
grab the name at the moment of the connection creating the prefix rather
than deferring to later.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 1b15dca)
@mergify mergify bot added the Backported This PR has been backported label Oct 12, 2020
@jackkoenig jackkoenig deleted the improve-recursive-naming branch October 12, 2020 23:36
mergify bot added a commit that referenced this pull request Oct 13, 2020
* When prefixing with a data, eagly get local name (#1614)

Fixes #1606

Previously, the Data itself would be put on the prefix stack and its
full name would be used as the prefix for subsequent names. This meant
that prefixes would grow quadratically as the prefix is present both on
the Data pushed to the stack, and on the stack itself. This is fixed by
just using the "local" name of the Data being pushed on the stack.

A related issue is deferring the name resolution. This led to unintuitive
behavior when the name of a Data used as a prefix is overridden later
(usually when the Data is a return value). The overriding name would
show up in prefixes twice instead of once. It is much more intuitive to
grab the name at the moment of the connection creating the prefix rather
than deferring to later.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 1b15dca)

* Waive MiMa failures on package private methods

Co-authored-by: Jack Koenig <koenig@sifive.com>
@chick chick changed the title When prefixing with a data, eagly get local name When prefixing with a data, eagerly get local name Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Please Merge Accepted PRs that are ready to be merged. Useful when waiting on CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quadratic naming with recursive functions
2 participants